<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div id="root">
        <h2>当前的n值是：<span v-text="n"></span></h2><br>
        <h2>放大10倍后的n值是：<span v-big="n"></span></h2><br>
        <button @click="n++">点我n+1</button>
        <hr>
        <input type="text" v-fbind:value="n">
    </div>

    <script>
        new Vue({
            el: '#root',
            data: {
                n: 1
            },
            directives: {
                big(element, binding) {
                    element.innerText = binding.value * 10
                },
                fbind: {
                    // 指令与元素成功绑定时
                    bind(element, binding) {
                        element.value = binding.value
                    },
                    // 指令所在元素被插入页面时
                    inserted(element, binding) {
                        element.focus()
                    },
                    // 指令所在的模板被重新解析时
                    update(element, binding) {
                        element.value = binding.value
                    }
                }
            }
        })
    </script>
</body>
</html>